package com.thinkgsp.jxc.model;

import java.io.Serializable;
import java.math.BigDecimal;

import org.apache.commons.lang.builder.ToStringBuilder;
import org.apache.commons.lang.builder.ToStringStyle;

import com.thinkgsp.util.XlsFieldAnnotation;
import com.thinkgsp.util.XlsValueType;

/**
 * 产品类,
 * @author evan
 *
 */
public class Product extends BaseModel implements Serializable {

	private static final long serialVersionUID = -907898400051517458L;
	
	private Integer productId;					//Required
	private Integer classifyId;					//Required
	private Integer repositoryId;
	@XlsFieldAnnotation(ChsName="产品编码",MethodName="getProductCode")
	private String productCode;					//Required
	@XlsFieldAnnotation(ChsName="产品名称",Width="30",MethodName="getProductName")
	private String productName;					//Required
	private String productBusName;	
	@XlsFieldAnnotation(ChsName="包装规格",MethodName="getPackSpec")
	private String packSpec;
	private Integer manufId;
	@XlsFieldAnnotation(ChsName="生产企业",MethodName="getManuf")
	private String manuf;
	private String unit;						//Required
	@XlsFieldAnnotation(ChsName="单位",MethodName="getUnit")
	private Integer innerPack;
	private Integer boxPack;
	private String abc;
	private Integer qtyScale = 0;				//Required
	private Integer priceScale = 2;				//Required
	private Boolean deleted = false;			//Required
	private Boolean virtual = false;			//Required
	private String licenseNo;
	private Boolean batchMgr = false;			//Required
	private String barcode;
	private String remark;
	private BigDecimal taxRate = new BigDecimal("0.17");
	@XlsFieldAnnotation(ChsName="产品类别",MethodName="getProductClassify",RefType=XlsValueType.RefClass)
	private ProductClassify productClassify;
	@XlsFieldAnnotation(ChsName="产品商业属性",MethodName="getProductBusProperties",RefType=XlsValueType.RefClass)
	private ProductBusProperties productBusProperties;
	private ProductLogisticsProperties productLogisticsProperties;
	private ProductMedicineProperties productMedicineProperteis;
	private ProductManuf productManuf;
	
	
	/**
	 * 产品ID
	 * @return
	 */
	public Integer getProductId() {
		return productId;
	}

	/**
	 * 设置产品ID,如果是新增产品不建议设置productId,因为系统会自动分配，
	 * 如果您设置的productId,系统将不进行插入操作，而是update操作。
	 * @param productId
	 */
	public void setProductId(Integer productId) {
		this.productId = productId;
	}

	/**
	 * 产品分类ID
	 * @return
	 */
	public Integer getClassifyId() {
		return classifyId;
	}

	public void setClassifyId(Integer classifyId) {
		this.classifyId = classifyId;
	}

	/**
	 * 知识库ID,该字段目前尚未使用
	 * @return
	 */
	public Integer getRepositoryId() {
		return repositoryId;
	}

	public void setRepositoryId(Integer repositoryId) {
		this.repositoryId = repositoryId;
	}

	/**
	 * 产品编码
	 * @return
	 */
	
	public String getProductCode() {
		return productCode;
	}

	public void setProductCode(String productCode) {
		this.productCode = productCode;
	}

	/**
	 * 产品名称
	 * @return
	 */
	public String getProductName() {
		return productName;
	}

	/**
	 * 商品名,一般指药品的注册商品名称
	 * @return
	 */
	public String getProductBusName() {
		return productBusName;
	}
	
	public void setProductBusName(String productBusName) {
		this.productBusName = productBusName;
	}
	
	public void setProductName(String productName) {
		this.productName = productName;
	}

	/**
	 * 包装规格
	 * @return
	 */
	public String getPackSpec() {
		return packSpec;
	}

	public void setPackSpec(String packSpec) {
		this.packSpec = packSpec;
	}

	/**
	 * 生产企业ID,用于关联生产企业名称表
	 * @return
	 */
	public Integer getManufId() {
		return manufId;
	}

	public void setManufId(Integer manufId) {
		this.manufId = manufId;
	}

	/**
	 * 生产企业
	 * @return
	 */
	public String getManuf() {
		return manuf;
	}

	public void setManuf(String manuf) {
		this.manuf = manuf;
	}

	/**
	 * 最小销售单位
	 * @return
	 */
	public String getUnit() {
		return unit;
	}
	
	public void setUnit(String unit) {
		this.unit = unit;
	}

	/**
	 * 中包装数量
	 * @return
	 */
	public Integer getInnerPack() {
		return innerPack;
	}

	public void setInnerPack(Integer innerPack) {
		this.innerPack = innerPack;
	}

	/**
	 * 箱装数量
	 * @return
	 */
	public Integer getBoxPack() {
		return boxPack;
	}

	public void setBoxPack(Integer boxPack) {
		this.boxPack = boxPack;
	}

	/**
	 * abc分类,其值一般为 a , b , c
	 * @return
	 */
	public String getAbc() {
		return abc;
	}

	public void setAbc(String abc) {
		if(abc != null) {
			this.abc = abc.toUpperCase();
		}
	}

	/**
	 * 数量小数位数,用于本商品在单据与存货中的数量小数位数,其值范围: 0 - 3,默认值0
	 * @return
	 */
	public Integer getQtyScale() {
		return qtyScale;
	}

	public void setQtyScale(Integer qtyScale) {
		this.qtyScale = qtyScale;
	}

	/**
	 * 单价小数位数,用于本商品在单据与存货中的单价小数位数,其值范围: 0 - 4,默认值 2
	 * @return
	 */
	public Integer getPriceScale() {
		return priceScale;
	}

	public void setPriceScale(Integer priceScale) {
		this.priceScale = priceScale;
	}

	/**
	 * 商品禁用标志,true : 禁用; false 启用
	 * @return true = 禁用; false = 启用
	 */
	public Boolean isDeleted() {
		return deleted;
	}

	public void setDeleted(Boolean deleted) {
		this.deleted = deleted;
	}

	/**
	 * 虚拟商品标志, true : 虚拟商品 ; false 实物商品,虚拟商品没有实际库存
	 * @return true : 虚拟商品 ; false 实物商品
	 */
	public Boolean isVirtual() {
		return virtual;
	}

	public void setVirtual(Boolean virtual) {
		this.virtual = virtual;
	}

	/**
	 * 药品的批准文号
	 * @return
	 */
	public String getLicenseNo() {
		return licenseNo;
	}

	public void setLicenseNo(String licenseNo) {
		this.licenseNo = licenseNo;
	}

	/**
	 * 批号管理标志 true : 批号管理 ; false : 非批号管理
	 * @return true : 批号管理 ; false : 非批号管理
	 */
	public Boolean isBatchMgr() {
		return batchMgr;
	}

	public void setBatchMgr(Boolean batchMgr) {
		this.batchMgr = batchMgr;
	}

	/**
	 * 产品条码
	 * @return
	 */
	public String getBarcode() {
		return barcode;
	}

	public void setBarcode(String barcode) {
		this.barcode = barcode;
	}

	/**
	 * 备注信息
	 * @return
	 */
	public String getRemark() {
		return remark;
	}

	public void setRemark(String remark) {
		this.remark = remark;
	}

	/**
	 * 产品分类
	 * @return
	 */
    public ProductClassify getProductClassify() {
		return productClassify;
	}

	public void setProductClassify(ProductClassify productClassify) {
		this.productClassify = productClassify;
		this.classifyId = productClassify.getClassifyId();
	}

	/**
	 * 产品商业属性
	 * @return
	 */
	public ProductBusProperties getProductBusProperties() {
		return productBusProperties;
	}

	public void setProductBusProperties(ProductBusProperties productBusProperties) {
		this.productBusProperties = productBusProperties;
	}

	/**
	 * 产品物流属性
	 * @return
	 */
	public ProductLogisticsProperties getProductLogisticsProperties() {
		return productLogisticsProperties;
	}

	public void setProductLogisticsProperties(
			ProductLogisticsProperties productLogisticsProperties) {
		this.productLogisticsProperties = productLogisticsProperties;
	}

	/**
	 * 产品药物属性
	 * @return
	 */
	public ProductMedicineProperties getProductMedicineProperteis() {
		return productMedicineProperteis;
	}

	public void setProductMedicineProperteis(
			ProductMedicineProperties productMedicineProperteis) {
		this.productMedicineProperteis = productMedicineProperteis;
	}

	/**
	 * 产品生产企业
	 * @return
	 */
	public ProductManuf getProductManuf() {
		return productManuf;
	}

	public void setProductManuf(ProductManuf productManuf) {
		this.productManuf = productManuf;
		this.manufId = productManuf.getManufId();
		this.manuf = productManuf.getManufName();
	}

	/**
	 * @return the taxRate
	 */
	public BigDecimal getTaxRate() {
		return taxRate;
	}

	/**
	 * @param taxRate the taxRate to set
	 */
	public void setTaxRate(BigDecimal taxRate) {
		this.taxRate = taxRate;
	}

	/**
     * {@inheritDoc}
     */	
	@Override
	public String toString() {
		ToStringBuilder sb = new ToStringBuilder(this, ToStringStyle.DEFAULT_STYLE);
		sb.append("prodCode",this.productCode)
		  .append("prodName",this.productName)
		  .append("prodBusName",this.productBusName)
		  .append("packSpck",this.packSpec)
		  .append("manuf",this.manuf)
		  .append("unit",this.unit)
		  .append("BusProperties",this.productBusProperties)
		  .append("Classify",this.productClassify)
		  .append("LogisticsProperties",this.productLogisticsProperties)
		  .append("MedicineProperties",this.productMedicineProperteis)
		  .append("Manuf",this.productManuf);
		
		return sb.toString();
	}
    /**
     * {@inheritDoc}
     */
	@Override
	public boolean equals(Object o) {
		if(this == o) {
			return true;
		}
		if(!(o instanceof Product)) {
			return false;
		}
		final Product product = (Product)o;
		if(productId != null) {
			return productId.equals(product.getProductId());
		} else {
			return product.getProductId() == null;
		}
		//return !(productId != null ? !productId.equals(product.getProductId()) : product.getProductId() != null);
	}
    /**
     * {@inheritDoc}
     */
	@Override
	public int hashCode() {
		return (this.productId != null ? this.productId.hashCode() : 0);
	}

}
